﻿using ShkSimulation.core.template.model;

namespace ShkSimulation.carsharing {

	public record CarsharingConfig {

		public readonly static string StationResourceKey = "station";
		public readonly static string RoadResourceKey = "road";
		public readonly static string DemandResourceKey = "demand";
		
		public readonly static string NavigateEnableKey = "navigate.enable";
		public readonly static string NavigateRouterPathKey = "navigate.path";
		public readonly static string NavigateTypeKey = "navigate.type";        
		public readonly static string DispatchKey = "dispatch.enable";
		public readonly static string DispatchUpBoundKey = "dispatch.up";
		public readonly static string DispatchDownBoundKey = "dispatch.down";
		
		public static bool IsValidCarsharingConfig(InputConfig config) {
			bool dispatch = config.GetConfigValue<bool>(DispatchKey);
			bool navigate = config.GetConfigValue<bool>(NavigateEnableKey);
			return !string.IsNullOrEmpty(config.GetResourceValue(StationResourceKey)) &&
			       !string.IsNullOrEmpty(config.GetResourceValue(RoadResourceKey)) &&
			       !string.IsNullOrEmpty(config.GetResourceValue(DemandResourceKey)) &&
			       (!navigate || (navigate && !string.IsNullOrEmpty(config.GetConfigValue<string>(NavigateRouterPathKey)))) &&
			       (!dispatch  || (dispatch && config.GetConfigValue<int>(DispatchUpBoundKey) > config.GetConfigValue<int>(DispatchDownBoundKey)));
		}

	}

}